<?php
/**
 * @name IndexController
 * @author 6p2b7gaqkyoe4aw\administrator
 * @desc 默认控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
 */
class IndexController extends Yaf_Controller_Abstract {

	public function init(){
		//$this->_layout = Yaf_Registry::get('layout');
	}
	
	public function getconfigAction(){
		//读取配置文件
		$config = Yaf_Application::app()->getConfig();
		//打印配置信息
		echo '<pre>';
		print_r($config);
		echo '</pre>';
	}
	/** 
     * 默认动作
     * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
     * 对于如下的例子, 当访问http://yourhost/qungbang/index/index/index/name/6p2b7gaqkyoe4aw\administrator 的时候, 你就会发现不同
     */
	public function indexAction($name = "Stranger") {
		//1. fetch query
// 		$get = $this->getRequest()->getQuery("get", "default value");
      
// 		//2. fetch model
// 		$model = new SampleModel();

// 		//3. assign
// 		$this->getView()->assign("content", $model->selectSample());
// 		$this->getView()->assign("name", $name);

// 		//4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
//         return TRUE;
		
		//$this->getView()->display('../../theme/default2/dist/index.html');
		$this->getView()->display('index/default2.phtml');
		
		//$this->_layout->meta_title = '前台首页';
	}
	
    public function artilceAction() {
		// 		header("Content-type: text/html; charset=utf-8");
		echo 123; die();
		$article_model=new ArticleModel();
		$article_one=$article_model->get_article(2);
	}
	
	public function test1Action() {
		echo 123;
	}
	
	public function testAction() {
// 		header("Content-type: text/html; charset=utf-8");
     
	$article_model=new ArticleModel();
	$article_one=$article_model->get_article();
	print_r($article_one);
	//$pdo = new PDO("sqlsrv:Server=47.93.35.3,1433;Database=qungbang","sa","HWSp29qCGEAHBmfnah") or die('连接sql错误') ;
	//$db = new NotORM($pdo);
	//$db = mssql::GetInstance();
       // $result = $db->test();
       die();
		include(APP_PATH.'\library\NotORM.php');
		try {
			$pdo = new PDO("sqlsrv:Server=47.93.35.3,1433;Database=qunbang","sa","HWSp29qCGEAHBmfnah");
		} catch (PDOException $e) {
			echo"Failed to get DB handle: ".$e->getMessage() ."n";
			exit;
		}
		
		$db = new NotORM($pdo);
		///$db->test()->fetch('content');
	//	die();
		
	    foreach ($db->qb_article() as $news) { 
         echo $news["content"].'</br>';
        }
		die();
	}
	
}
